package pl.cvplus.entity;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: Piotrek
 * Date: 02.03.12
 * Time: 23:16
 * To change this template use File | Settings | File Templates.
 */
@javax.persistence.Table(name = "cp_role", schema = "public", catalog = "")
@Entity
public class CpRole {
    private Integer id;

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    private String roleName;

    @javax.persistence.Column(name = "role_name", nullable = false, insertable = true, updatable = true, length = 50, precision = 0)
    @Basic
    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    private String description;

    @javax.persistence.Column(name = "description", nullable = true, insertable = true, updatable = true, length = 100, precision = 0)
    @Basic
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CpRole cpRole = (CpRole) o;

        if (description != null ? !description.equals(cpRole.description) : cpRole.description != null) return false;
        if (id != null ? !id.equals(cpRole.id) : cpRole.id != null) return false;
        if (roleName != null ? !roleName.equals(cpRole.roleName) : cpRole.roleName != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (roleName != null ? roleName.hashCode() : 0);
        result = 31 * result + (description != null ? description.hashCode() : 0);
        return result;
    }

    private Collection<CpUserRoles> cpUserRolesesById;

    @OneToMany(mappedBy = "cpRoleByRoleFk")
    public Collection<CpUserRoles> getCpUserRolesesById() {
        return cpUserRolesesById;
    }

    public void setCpUserRolesesById(Collection<CpUserRoles> cpUserRolesesById) {
        this.cpUserRolesesById = cpUserRolesesById;
    }
}
